package com.design;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;

import com.receive.ClientRecv;
import com.request.ClientDetails;



public class ClientForm implements ActionListener
{
	JFrame mainform;
	JPanel top,middle,bottom,bottom1;
	JPanel mainpanel,payment,accounts,smsbanking,estatement;
	JButton bpayment,baccounts,bsmsbanking,bestatement;
	Layers layers=new Layers();
	JMenuBar mb;
	JButton jclose=new JButton();
	JMenu reg,pay,acc,sms,est;
	JMenuItem pay1,pay2,pay3,acc1,acc2,acc3,sms1,reg1,estat;
	JPanel temp=new JPanel();
	private ClientDetails clientDetails=null;
	public static String nodeName=null; 
	
	
	public ClientForm() 
	{
		mainform=new JFrame();
		
		clientDetails=new ClientDetails();
		nodeName=clientDetails.Rand();
		mainform.setTitle("Client");
		Dimension di=mainform.getToolkit().getScreenSize();
		int width=di.width;
		int height=di.height;
		int wi=(width-800)/2;
		int he=(height-600)/2;
		
		mainpanel=new JPanel();
		mainpanel.setLayout(null);
		
		

		top=new JPanel();
		top.setLayout(new FlowLayout());
		top.setBackground(new Color(171,12,87));
		top.setBounds(0,0,800,100);
		
		JLabel tit=new JLabel("E-BANKING");
		tit.setForeground(Color.yellow);
		tit.setFont(new Font("verdana",Font.BOLD,15));
		top.add(tit);
		
		mainpanel.add(top);
		middle=new JPanel();
		middle.setLayout(new BorderLayout());
		middle.setBackground(new Color(171,12,87));
		middle.setBounds(0,100,800,30);
		
		
		/*************************************/

		middle.add(menudet());
	
		/*************************************/
		mainpanel.add(middle);
		bottom=new JPanel();
		smsbanking=layers.SmsBanking(bottom);
		
		bottom.setLayout(null);
		//bottom.setBackground(new Color(0,0,0));
		bottom.setBounds(0,130,800,450);
		mainpanel.add(bottom);
		
		
		bottom1=new JPanel();
		bottom1.setLayout(null);
		jclose=new JButton("close");
		jclose.setBounds(350, 16, 100, 20);
		jclose.addActionListener(this);
		bottom1.add(jclose);
		//bottom1.setLayout(new BorderLayout());
		bottom1.setBackground(new Color(171,12,87));
		//bottom1.setBackground(new Color(0,0,0));
		bottom1.setBounds(0,580,800,450);
		mainpanel.add(bottom1);
		//payment=layers.CreditPayments();
		/*accounts=new JPanel();
		smsbanking=layers.SmsBanking();
		estatement=new JPanel();*/
		//bottom.add(new JPanel());
		
		
		
		mainform.add(mainpanel);
		mainform.setLocation(wi,he);
//		mainform.setUndecorated(true);
		mainform.setSize(800,630);
		mainform.setVisible(true);
		temp=bottom;
		
	}
	public JMenuBar menudet()
	{
		mb=new JMenuBar();
		mb.setLayout(new GridLayout(1,5));
		mb.setBackground(new Color(171,12,87));
		
		 reg=new JMenu("Register");
		 pay=new JMenu("Payment");
		 acc=new JMenu("Accounts");
		 sms=new JMenu("SMS-Banking");
		 //est=new JMenu("E-Statement");

		reg.setForeground(Color.YELLOW);
		reg.setFont(new Font("Comic Sans Ms",Font.BOLD,15));
				
		pay.setForeground(Color.YELLOW);
		pay.setFont(new Font("Comic Sans Ms",Font.BOLD,15));;
		
		acc.setForeground(Color.YELLOW);
		acc.setFont(new Font("Comic Sans Ms",Font.BOLD,15));;
		
		sms.setForeground(Color.YELLOW);
		sms.setFont(new Font("Comic Sans Ms",Font.BOLD,15));;
		
		//est.setForeground(Color.YELLOW);
		//.setFont(new Font("Comic Sans Ms",Font.BOLD,15));;
		
		
		sms1=new JMenuItem("SMS Banking");
		reg1=new JMenuItem("Registration");
		pay2=new JMenuItem("Payment");
		reg.add(pay2);
		sms.add(sms1);
		
		 pay1=new JMenuItem("Bill Payment");
		 
		 pay3=new JMenuItem("Cheque Payments");
		pay.add(pay1);
		//pay.add(pay2);
		pay.add(pay3);
		
		
		
		 acc1=new JMenuItem("Account Transfers");
		 acc2=new JMenuItem("Third Party Transfers");
		 acc3=new JMenuItem("Cheque Status");
		acc.add(acc1);
		//acc.add(acc2);
		acc.add(acc3);
		
		//JMenuItem sms1=new JMenuItem("1");
		//JMenuItem sms2=new JMenuItem("2");
		//JMenuItem sms3=new JMenuItem("3");
		//sms.add(sms1);
		//sms.add(sms2);
		//sms.add(sms3);
		//estat=new JMenuItem("E-state");
		//est.add(estat);
		pay1.addActionListener(this);
		pay2.addActionListener(this);
		pay3.addActionListener(this);
		acc1.addActionListener(this);
		acc2.addActionListener(this);
		acc3.addActionListener(this);
		sms1.addActionListener(this);
		reg1.addActionListener(this);
		//estat.addActionListener(this);
		mb.add(reg);
		mb.add(pay);
		mb.add(sms);
		mb.add(acc);
		//mb.add(est);
		
		return mb;
		
	}
	
 public static void main(String args[])
 {
	 new ClientForm();
 }
public void actionPerformed(ActionEvent arg0) 
{

	System.out.println("dddd");
	if(arg0.getSource()==jclose)
	{
		mainform.setVisible(false);
	}
	if(arg0.getSource()==pay1)
	{
		RemoveComp(bottom);
		mainpanel.add(layers.PaymentsViews(bottom));
		mainform.repaint();
		mainpanel.repaint();
		bottom.repaint();
		
	}
	if(arg0.getSource()==pay2)
	{
		RemoveComp(bottom);
		mainpanel.add(layers.RegisterBillPayement(bottom));
		mainform.repaint();
		mainpanel.repaint();
		bottom.repaint();
	}
	if(arg0.getSource()==pay3)
	{
		RemoveComp(bottom);
		mainpanel.add(layers.ChequePayments(bottom));
		mainform.repaint();
		mainpanel.repaint();
		bottom.repaint();
	}
	if(arg0.getSource()==acc1)
	{
		RemoveComp(bottom);
		mainpanel.add(layers.AccountsTransfer(bottom));
		mainform.repaint();
		mainpanel.repaint();
		bottom.repaint();
	}
	if(arg0.getSource()==acc2)
	{
		RemoveComp(bottom);
		mainpanel.add(layers.ThridPartyTraansfer(bottom));
		mainform.repaint();
		mainpanel.repaint();
		bottom.repaint();
	}
	if(arg0.getSource()==acc3)
	{
		RemoveComp(bottom);
		mainpanel.add(layers.chequeStatus(bottom));
		mainform.repaint();
		mainpanel.repaint();
		bottom.repaint();
	}
	if(arg0.getSource()==sms1)
	{
		RemoveComp(bottom);
		System.out.println("AAAAAAAAAAA");

		mainpanel.add(layers.SmsBanking(bottom));
		
		mainform.repaint();
		mainpanel.repaint();
		bottom.repaint();
		
	}
	if(arg0.getSource()==reg1)
	{
		RemoveComp(bottom);
		System.out.println("AAAAAAAAAAA");

		mainpanel.add(layers.Registration(bottom));
		
		mainform.repaint();
		mainpanel.repaint();
		bottom.repaint();
		reg.setEnabled(false);
	}
	if(arg0.getSource()==estat)
	{
		RemoveComp(bottom);
		System.out.println("AAAAAAAAAAA");

		mainpanel.add(layers.Estatement(bottom));
		
		mainform.repaint();
		mainpanel.repaint();
		bottom.repaint();
	}
}
public void RemoveComp(JPanel bot)
{
	bot.removeAll();
}
}
